package com.kuiandjie.service;

import java.util.List;

import com.kuiandjie.dao.TaskDao;
import com.kuiandjie.entity.Task;

public class TaskService {
	TaskDao td = new TaskDao();

	public List<Task> findTaskByGid(String curgid) {
		return td.findTaskByGid(curgid);
	}

	public void addTask(String taskName, String state, String level,
			String beginTime, String endTime, String desc, int empId, int id,
			String now) {
		Task task = new Task();
		task.setName(taskName);
		task.setState(state);
		task.setBeginTime(beginTime);
		task.setEndTime(endTime);
		task.setCreateTime(now);
		task.setDesc(desc);
		task.setEmployeeId(empId);
		task.setProgress(0);
		task.setGoalId(id);
		task.setLevel(level);
		td.insertTask(task);
	}

	public void editTaskByLeader(int taskId, String taskName, String state,
			String level, String beginTime, String endTime, String desc,
			int empId, String now) {
		Task task = new Task();
		task.setId(taskId);
		task.setName(taskName);
		task.setState(state);
		task.setBeginTime(beginTime);
		task.setEndTime(endTime);
		task.setDesc(desc);
		task.setEmployeeId(empId);
		task.setLevel(level);
		
		td.editByLeader(task);
	}

	public void editTaskByMember(int taskId, String state, int progress) {
		Task task = new Task();
		task.setId(taskId);
		task.setState(state);
		task.setProgress(progress);
		
		td.editByMember(task);
	}

	public Task findTaskByTaskIdAndEmpId(int curTaskId, int nameId) {
		return td.findTaskByTaskIdAndEmpId(curTaskId, nameId);
	}

	public Task findTaskByTaskId(int curTaskId) {
		return td.findById(curTaskId);
	}

	public List<Task> findTaskByEidAndPid(int cureid, String curpid) {
		return td.findTaskByEidAndPid(cureid,curpid);
	}

	
}
